Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #93316: slur still lays out to deleted note #2343

Merged
merged 1 commit into from Jan 22, 2016

Conversation

MarcSabatella
Copy link
Contributor

This code works and should be safe to the extent I understand the spanner map implementation, which is not very well. Main question to me is if there is a better / more direct way to find the spanners attached to this chordrest. I borrowed this code from ChordRest::accessibleExtraInfo().

@MarcSabatella
Copy link
Contributor Author

Test failure might be real, but I suspect it will turn out to be a case of the reference expecting the buggy result.

@MarcSabatella
Copy link
Contributor Author

Failure was real; the splitstaff function needed to be updated to fix up slurs before deleting the original note rather than after.

// spanners with this cr as start or end element will need relayout
SpannerMap& smap = score()->spannerMap();
auto spanners = smap.findOverlapping(tick(), tick());
for (auto i = spanners.begin(); i < spanners.end(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use auto everywhere.

auto spanners = smap.findOverlapping(tick(), tick());
for (auto interval : spanners) {

@lasconic
Copy link
Contributor

Looks good. Could you harmonize the calls to findOverlapping() with auto? Also in other files and squash the commits together? Thanks!

@MarcSabatella
Copy link
Contributor Author

OK, will do. "auto" is relatively new to me so I've never been clear on how it works or when it is most appropriate to use, but I think I get it.

@MarcSabatella
Copy link
Contributor Author

Done, and tested each case to be sure they worked.

BTW, I noted sometimes we used constructions like:

for (auto interval : findOverlapping(tick, tick))

with the call to findOverlapping within the "for" loop. Some of these were "foreach" loops. I'm not really sure if that gets re-evaluated every time throug, and I'm also not sure if any of these call mights have problems with removing elements from the listed being iterated over. I decided to standardize all of these to look more like:

auto spanners = findOverlapping(tick, tick);
for (auto interval : spanners)

@lasconic
Copy link
Contributor

As far as I understand we don't remove the spanner from the map we iterate on. So we should be fine.

lasconic added a commit that referenced this pull request Jan 22, 2016
fix #93316: slur still lays out to deleted note
@lasconic lasconic merged commit d13e240 into musescore:master Jan 22, 2016
@@ -446,7 +446,8 @@ bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns, int st

int tick1 = m1->tick();
int tick2 = m2->endTick();
for (auto i : s->spannerMap().findContained(tick1, tick2))
auto spanners = s->spannerMap().findContained(tick1, tick2);
for (auto i : spanners)
undo(new RemoveElement(i.value));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWI, this was what I was concerned about when I thought maybe we might be removing from the list we were iterating on, depending on exactly how those loops are evaluated. Probably there was never a problem because either findContained() is re-evaluated on each iteration, or the result of findContained() was stored in a temporary variable and removing from the score might be removed from the spanner map but the temporary variable wouldn't be affected. Still it seemed awkward, so I just made this look like the others, first calling findContained() and then initiating the loop.

Same story with the call in joinMeasures() a little farther down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants